import ConfigMarks from "../config-marks.js";
import FactoryMaterial from "../factory/factory-material.js";

export default {
	// 图片
	point1: (position, option = {}) => {
		return new mars3d.graphic.BillboardEntity({
			position,
			style: {
				setHeight: ConfigMarks.baseHeight + 50,
				image: "http://115.29.192.252:39000/public/logo.png",
				scale: 2,
				horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
				verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
				scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 500000, 0.1),
				...option
			},
			attr: {
				name: "扩展属性"
			}
		})
	},
	// 扩散光圈
	pointCircleWave: (position, option = {}) => {
		return new mars3d.graphic.CirclePrimitive({
			position,
			style: {
				setHeight: ConfigMarks.baseHeight + 50,
				radius: 80000,
				materialType: mars3d.MaterialType.CircleWave,
				materialOptions: {
					color: "rgba(251,250,125,1)",
					count: 2,
					speed: 5
				},
				...option
			}
		})
	},
	// 复杂动画1
	pointLightCone: (position, option = {}) => {
		return new mars3d.graphic.LightCone({
			position,
			style: {
				setHeight: ConfigMarks.baseHeight + 50,
				color: "rgba(251,250,125,1)",
				radius: 24000, // 底部半径
				height: 600000, // 椎体高度
				...option
			},
			show: true
		})
	},
	// 锥形动画光标 - 上下浮动
	pointTetrahedron: (position, option = {}) => {
		return new mars3d.graphic.Tetrahedron({
			position: [position[0], position[1], ConfigMarks.baseHeight + 5000],
			style: {
				width: 40000,
				height: 50000,
				color: "rgba(251,250,125,1)",
				moveHeight: 50000,
				...option
			}
		})
	},
	routeImg(position) {
		// 旋转的图片 -- 底部
		let rotation = Cesium.Math.toRadians(50)

		function getRotationValue() {
			rotation -= 0.007
			return rotation
		}
		return new mars3d.graphic.CircleEntity({
			position: [position[0], position[1], ConfigMarks.baseHeight + 5000],
			style: {
				radius: 50000,
				height: 5000,
				materialType: mars3d.MaterialType.Image2,
				materialOptions: {
					image: "http://115.29.192.252:39000/public/logo.png"
				},
				rotation: new Cesium.CallbackProperty(getRotationValue, false),
				stRotation: new Cesium.CallbackProperty(getRotationValue, false)
			}
		})
	},
	routeImgWall(position) {
		// 旋转的图片 -- 中心围墙
		const WallImagePositions = mars3d.PolyUtil.getEllipseOuterPositions({
			position: [position[0], position[1], ConfigMarks.baseHeight + 50],
			radius: 50, // 半径
			count: 50 // 共返回(count*4)个点
		})
		const rotatWallImage = new mars3d.graphic.WallPrimitive({
			positions: WallImagePositions,
			style: {
				diffHeight: 1900,
				closure: true,
				materialType: mars3d.MaterialType.RectSlide,
				materialOptions: {
					image: "http://115.29.192.252:39000/public/logo.png",
					speed: 2
				}
			}
		})
		return rotatWallImage;
	},
	pointCircle(position) {
		// 圆柱
		const graphic = new mars3d.graphic.CircleEntity({
			position: [position[0], position[1], ConfigMarks.baseHeight + 50],
			style: {
				radius: 50000.0,
				diffHeight: 300000.0,
				// color: "#00ff00",
				opacity: 0.3,
				rotationDegree: 45,
				// 高亮时的样式（默认为鼠标移入，也可以指定type:'click'单击高亮），构造后也可以openHighlight、closeHighlight方法来手动调用
				highlight: {
					opacity: 0.8
				},
				...FactoryMaterial.polyGradient(),
			}
		})
		return graphic;
	},
	pointCircleEntity(position) {
		// 波纹扩散
		return new mars3d.graphic.CircleEntity({
			position: [position[0], position[1], ConfigMarks.baseHeight + 500],
			style: {
				radius: 50000.0,
				materialType: mars3d.MaterialType.CircleWave,
				materialOptions: {
					// color: "#ff0000",
					color: new Cesium.CallbackProperty(function() {
						return "rgba(251,250,125,1)"
					}, false),
					count: 1, // 单个圆圈
					speed: 20
				}
			}
		});
	},
	pointModelZhanji(position) {
		const point = new mars3d.LngLatPoint(position[0], position[1], ConfigMarks.baseHeight + 500);
		// 添加模型
		return new mars3d.graphic.ModelEntity({
			position: point,
			style: {
				url: "//data.mars3d.cn/gltf/mars/zhanji.glb",
				scale: 1,
				minimumPixelSize: 50
			}
		})
	},
	pointCylinder(position) {
		const point = new mars3d.LngLatPoint(position[0], position[1], ConfigMarks.baseHeight + 500);
		// 效果1
		const pointQY = point.clone()
		pointQY.alt = pointQY.alt / 2

		return new mars3d.graphic.CylinderEntity({
			position: pointQY,
			style: {
				pitch: 180,
				roll: 60,
				length: 150000,
				topRadius: 25000,
				bottomRadius: 70000,
				...FactoryMaterial.WallScroll()
			}
		})
	},
	pointAreaName(position, text) {
		let param = {
			position: position,
			style: {
				image: "/admin/static/img/map/map-city-icon.png",
				"scale": 1,
				"horizontalOrigin": 0,
				"verticalOrigin": 1,
				"clampToGround": true,
				"opacity": 1,
				"scaleByDistance": false,
				"distanceDisplayCondition": false,
				"visibleDepth": false,
				// "highlight": {
				// 	"scale": 1.5
				// },
				"label": {
					"text": " " + text,
					"pixelOffsetY": -24,
					"clampToGround": true,
					"font_family": "隶书",
					"font_size": 20,
					"outline": false,
					"background": true,
					"backgroundColor": "rgba(12,20,38,1)",
					"pixelOffsetX": 11 * (text.length || 0) + 2,
					"visibleDepth": true,
					"backgroundPadding": 3
				},
			}
		}
		return new mars3d.graphic.BillboardEntity(param);
	}
}
